<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('导入外包批次')" />
</head>
<body class="gray-bg">
<input type="hidden" id="rowIds">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label class="control-label">产品类型：</label>
                            <select name="partType" th:with="type=${osMesPartType}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}"
                                        th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}">
                                </option>
                            </select>
                        </li>
                        <li>
                            <label class="control-label">批号：</label>
                            <input type="text" name="lotId"/>
                        </li>
                        <li>
                            <label class="control-label">产品名称：</label>
                            <input type="text" name="partName"/>
                        </li>
                        <li>
                            <label class="control-label">工步名称：</label>
                            <input type="text" name="stepName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search();"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "report/wiplot";
    var columns = [
        {
            checkbox: true
        },
        {
            field : 'lotId',
            title : '批号',
            sortable: true
        },
        {
            field : 'partType',
            title : '产品类型',
            sortable: true
        },
        {
            field : 'partName',
            title : '产品名称',
            sortable: true
        },
        {
            field : 'mainQty',
            title : '数量'
        },
        {
            field : 'stepName',
            title : '工步名称',
            sortable: true
        },
        {
            field : 'stepDesc',
            title : '工步描述'
        },
        {
            field : 'state',
            title : '状态'
        }
    ];

    var options = {
        url: prefix + "/outsource/importlot/list",
        showSearch: false,
        showRefresh: false,
        showToggle: false,
        showColumns: false,
        sidePagination: "client",
        pageList: [10, 25, 50],
        striped: true,
        columns: columns
    };

    $(function() {
        $.table.init(options);
    });

    /* 添加用户-选择用户-提交(子页面调用父页面形式) */
    function submitHandler(index, layero) {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.close();
        // 父页面的变量
        activeWindow().$('#userids').html('我是通过方式一来的：' + rows.join());
    }

    /* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
    function getSelections() {
        return $.table.selectFirstColumns();
    }

    $("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
        var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
        var rowIds = $.table.affectedRowIds(rows);
        var selectedFirstColumns = $.table.selectFirstColumns();
        $("#rowIds").val(selectedFirstColumns);
    });
</script>
</body>
</html>